home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / TINPUT.TXT < prev    next >
Text File  |  1996-07-04  |  26KB  |  507 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   TINPUT  .TXT ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18.  ┌──────────────────────────────────────────────────────────────────┐
  19.  │   fTinput$ and fTinputM$ both use the same TINPUT_?.INC files.   │
  20.  └──────────────────────────────────────────────────────────────────┘
  21.  
  22.  Before you get into all of this: The info in this file is vital but,
  23.  despite the length of the file it is  NOT difficult to understand if
  24.  you don't try to make it into something more than it is. The concept
  25.  was taught to me by my guru in about 30 seconds on the margin of the
  26.  daily news paper! So, if I can grasp it that fast, nuff said! d;D
  27.  
  28.  A program is not worth much if it cannot input data and instructions
  29.  from the user; how this information  and data is input is one of the
  30.  most important features of any program.  It should be as easy and as
  31.  fool-proof as possible. Your job, as programmer, is to make all this
  32.  happen.
  33.  
  34.  As there are several different types of data one all-purpose routine
  35.  just doesn't make the cut!  On the other hand, to attempt to have an
  36.  individual routine for each style is just too much to handle. I have
  37.  come up with a happy medium:  a suite of routines that allows you to
  38.  call a single function from within your program. It calls a specific
  39.  handler for the data style required.  Sorta' like one stop shopping!
  40.  
  41.  There are 9 field styles. Eight of them provide specific support and
  42.  the ninth is a general,  all-purpose field  that catches  everything
  43.  else.  The fields are controlled by a string of data  that you send.
  44.  The string is loaded into a TYPE by the function before it is passed
  45.  to the specific handler.
  46.  
  47.  As you can see the first  8 bytes of the control string fit into the
  48.  TYPE  but from position nine and on  you can also send more data for
  49.  some of the styles that require it  or can use it.  This area of the
  50.  string is known an the MASK.  Also, not all the members of the  TYPE
  51.  are used by all the styles and  .Misc is a kind of catch-all member.
  52.  Despite their comings and goings,  the members hold their purpose in
  53.  life throughout.  Below is a generalized description for each member
  54.  then a style by style discussion.
  55.  
  56.  ┌──────────────────────────────────────────────────────────────────┐
  57.  │ One important thing to remember is that fTinput assumes that the │
  58.  │ incoming data is IN THE CORRECT FORMAT for the designated Style. │
  59.  └──────────────────────────────────────────────────────────────────┘
  60.  
  61.  TYPE TinputTYPE             '┌───────────────────────────────────
  62.    Style  AS STRING * 1      '│ field type ie: A,B,D,H,M,N,P,Q,T
  63.    Row    AS BYTE            '│ screen row
  64.    Col    AS BYTE            '│ left most screen column
  65.    Cols   AS BYTE            '│ N° of visible columns
  66.    MustBe AS BYTE            '│ > 0 if field is mandatory
  67.    Cased  AS BYTE            '│ 0 = none 1 = UCASEed 2 = LCASEed
  68.    Misc   AS BYTE            '│ max length of string => Cols
  69.    Just   AS BYTE            '│ N° of routine to call fJUSTIFY$ with
  70.  END TYPE                    '└────────────────────────┤ 9 bytes ├───
  71.  
  72.  .Style   always indicates which field driver to use
  73.  .Row     always the starting screen row for the field
  74.  .Col     always the left-most column(s) for the field
  75.  .Cols    always the maximum visible columns of the field
  76.           in most cases this is also the maximum length of the field
  77.  .MustBe  if > 0 then the field is mandatory
  78.           this field is used differently by each style
  79.  .Cased   if 0 then no casing is done to the input
  80.           if 1 then all input is UCASEd using UCASEstr
  81.           if 2 then all input is LCASEd using LCASEstr
  82.  .Misc    used differently by each style
  83.  .Just    an extra byte for your use as it is NOT used by fTinput$
  84.  
  85.  ──────────────────────────────────────────────────────────────────────────
  86.  ANYTHING GOES
  87.  ──────────────────────────────────────────────────────────────────────────
  88.   Style  = "A"         Anything goes
  89.   Row    = 1 -> x      screen row
  90.   Col    = 1 -> x      left most screen column
  91.   Cols   = 1 -> x      N° of visible columns
  92.   MustBe = 0 or x      > 0 if field is mandatory
  93.   Cased  = 0, 1 or 2   0 = NOCASING 1 = UCASEed 2 = LCASEed
  94.   Misc   = x           maximum field length if => Cols
  95.   Just   = x           NOT USED
  96.   Mask$  =             if NULL any characters accepted
  97.                        ELSE only chars in Mask$ eg: " 0123456789-"
  98.  
  99.   DATA IN : any string value from NULL to .Misc in length
  100.   DATA OUT: a string of up to .Col or .Misc length
  101.  
  102.   As you can see this field can and will scroll through a long string of
  103.   data. By using Mask$ you can restrict the keyboard input to only a few
  104.   keys. ie: "0123456789-() " works well for phone numbers
  105.  
  106.   Another property of Alpha is that it will automatically issue a CHR$(13)
  107.   if .Cols = 1 and an acceptable key is input. This allows you to use ALPHA
  108.   for yes/no answers and the like, but QUERY does a better job of it.
  109.  
  110.  ──────────────────────────────────────────────────────────────────────────
  111.  BLOCK O' TEXT
  112.  ──────────────────────────────────────────────────────────────────────────
  113.   Style  = "B"         Block of text
  114.   Row    = 1 -> x      top most screen row
  115.   Col    = 1 -> x      left most screen column
  116.   Cols   = 1 -> x      N° of columns
  117.   MustBe = NOT USED    0 is assumed
  118.   Cased  = NOT USED    0 is assumed
  119.   Misc   = x           maximum number of rows of .Cols chars
  120.   Just   = NOT USED
  121.   Mask$  = NOT USED
  122.  
  123.   DATA IN : any string of text
  124.   DATA OUT: a string of text
  125.  
  126.   A simple word-wrap is employed SEE: fWrapPosF%
  127.   <UP> and <DOWN> keys are used and <ENTER> acts as <DOWN>
  128.   fTinput$ can return <UP> and <DOWN> as defaults from this function
  129.  
  130.  ──────────────────────────────────────────────────────────────────────────
  131.  DATES
  132.  ──────────────────────────────────────────────────────────────────────────
  133.   Style  = "D"         Dates
  134.   Row    = 1 -> x      screen row
  135.   Col    = 1 -> x      left most screen column
  136.   Cols   = 8 or 10     8 is default ( + LEN(day$) )
  137.   MustBe = 0 or x      > 0 if field is mandatory
  138.   Cased  = NOT USED
  139.   Misc   = NOT USED
  140.   Just   = NOT USED
  141.   Mask$  = "Sun |Mon |Tue |Wed |Thr |Fri |Sat "
  142.                        NOTE: if Mask$ is used
  143.                              * all day names need be the same length
  144.                              * .Cols must include this length
  145.                              * D$ is _NOT_ effected
  146.                              The data field looks like "Mon 01-01-1995"
  147.                              and the user only inputs the date not the
  148.                              day.
  149.  DATA IN : an 8 or 10 character date string in SetDateFormat style
  150.  DATA OUT: same as data in
  151.  
  152.  If .MustBe > 0 and incoming D$ is NULL then the system's date is used
  153.  ELSE
  154.  Before the field exits the date entered must be a correct and legal date
  155.  or a NULL field will exit with a value of SPACE$(.Cols) and display.
  156.  
  157.  The grey       "*" resets the date to the current date
  158.                 "-" -  1 day  (yesterday)  ' these keys come in handy, along
  159.           <CTRL>"-" - 28 days (